{include file="common/head_s"/}  
<div class="main">
    <div class="userinfo">
        <div class="avatar"><img src="/static/user/images/avatar.jpg" alt="{$userInfo.username}"></div>
        <div class="infos">
            <div class="pull-left"> 
                {if $userInfo.state===0}
                <li><a class="layui-btn layui-btn-xs" id="trade" data-type="reload"><i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop">&#xe63d;</i> 交易中，点击停止交易</a></li> 
                {else if $userInfo.state===1}
                <li><a class="layui-btn layui-btn-danger layui-btn-xs" id="trade" data-type="reload"><i class="layui-icon">&#xe63d;</i> 停止交易，点击启动交易</a></li>
                {/if}
                {if $userInfo.voice=='open'}
                <li><a class="layui-btn layui-btn-xs" id="voice" data-type="reload"><i class="layui-icon">&#xe645;</i> 提示音开启，点击关闭</a></li> 
                {else if $userInfo.voice=='close'}
                <li><a class="layui-btn layui-btn-danger layui-btn-xs" id="voice" data-type="reload"><i class="layui-icon">&#xe688;</i> 提示音关闭，点击开启</a></li>
                {/if}
                <li><span class="value">姓名：</span><span class="name">{$userInfo.username}({$userInfo.level_name})</span></li>
                <li><span class="value">手机号：</span><span class="value">{$userInfo.mobile}</span></li>
                <li><span class="value">APPID：</span><span class="value">{$userInfo.appid}</span></li> 
                <li><span class="value">推荐上级：</span><span class="value">{$agentname}</span></li> 
            </div>
            <div class="pull-right"><div class="banks"><a href="{:url('user/financial/bank')}" target="main_pan"><i class="icon icon-credit-card"></i>收款账号管理</a></div></div>
        </div> 
    </div> 
    <div class="home_pan">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe63c;</i>订单统计<em class="pull-right">单位：个</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">待处理</span><span class="value">{$cdata.order_no}</span></div> 
                        <div class="layui-col-xs6"><span class="name">全部订单</span><span class="value">{$cdata.order_all}</span></div>  
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe65e;</i>财务汇总<em class="pull-right">单位：元</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">累计收款</span><span class="value">{$cdata.order_money}</span></div>   
                        <div class="layui-col-xs6"><span class="name">支付手续费</span><span class="value">{$cdata.order_money_pay}</span></div> 
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe857;</i>通道统计<em class="pull-right">单位：个</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">激活的通道</span><span class="value">{$cdata.channel_yes}</span></div> 
                        <div class="layui-col-xs6"><span class="name">全部通道</span><span class="value">{$cdata.channel_all}</span></div>    
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card-header">今日订单</div> 
    <!-- 未处理的订单 -->
    <div class="home_order"> 
        <table class="layui-table layui-hide" id="orderlist" lay-filter="listss"></table>
    </div>
    <!-- 未处理的订单 END-->
</div>
<script type="text/html" id="action">
    {{# if(d.state==0 && d.points==0){ }}
        <div class="layui-btn layui-btn-danger layui-btn-xs" lay-event="orderdel">删除</div>
    {{# }else{ }}
        <div class="layui-btn layui-btn-disabled layui-btn-xs">删除</div>
    {{# } }} 
</script>
<script type="text/html" id="payinfo"> 
    {{# if(d.bankid){ }}<div onmouseover="layer.tips('{{d.bank_name}}<br>收款账号：{{d.bank_no}}<br>支付时间：{{d.paytime}}',this,{area: 'auto',tips: [1, '#333']});" onmouseout="layer.closeAll();">{{d.payname}}</div>{{# } }} 
</script>
<script src="/static/plugins/layui/layui.js"></script>
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'listss',
            elem: '#orderlist',
            url: '{:url("order/index")}',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'orderid', title: '平台订单号',align: 'center', width:138, fixed: true},
                {field: 'cionname', title: '币种名称',align: 'center', width: 120, fixed: true},
                {field: 'money', title: '订单金额',align: 'center', width: 120, fixed: true}, 
                {field: 'price', title: '单价/CNY',align: 'center', width: 100},
                {field: 'number', title: '数量',align: 'center', width: 100},
                {field: 'state_name', title: '订单状态',align: 'center', width: 100}, 
                {field: 'points_name', title: '上分状态',align: 'center', width: 100}, 
                {field: 'payname', title: '支付信息',align: 'center', width: 100,templet: '#payinfo'}, 
                {field: 'fei_user', title: '手续费',align: 'center', width: 90},  
                {field: 'channelname', title: '所属通道',align: 'center', width: 120}, 
                {field: 'shopname', title: '所属商户',align: 'center', width: 120}, 
                {field: 'orderid_out', title: '商户订单号',align: 'center', width: 150},  
                {field: 'note', title: '备注信息',align: 'center', width: 120},  
                {field: 'addtime', title: '提交时间',align: 'center', width: 142}, 
                {title: '操作', width: 80,align: 'center', fixed:'right',toolbar: '#action'},
            ]],
            limit: 10,
            where: {timequan:'today'}
        });  
        //搜索
        $('#trade').on('click', function () {  
            var userid="{$userInfo.id}";
            var state="{$userInfo.state}";
            $.post("{:url('index/userstrade')}",{userid:userid,state:state},function(res){
                if(res.status===1){
                    layer.msg(res.msg,{time:1000,icon:1},function(){ 
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        });
        $('#voice').on('click', function () {  
            var userid="{$userInfo.id}";
            var voice="{$userInfo.voice}";
            $.post("{:url('index/usersvoice')}",{userid:userid,voice:voice},function(res){
                if(res.status===1){
                    layer.msg(res.msg,{time:1000,icon:1},function(){ 
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        });
        table.on('tool(listss)', function(obj) {
            var data = obj.data;
            if(obj.event === 'orderdel') {
                layer.confirm('您确定要删除该订单吗？', function(index){ 
                    $.post("{:url('order/del')}",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'checkpay') {
                layer.confirm('请确定您是否已经收到相应的款项！', function(index){ 
                    $.post("{:url('order/uppay')}",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                tableIn.reload();
                            });
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'shangfeng') {  
                layer.open({
                    type: 1 
                    ,id: 'shangfeng' //防止重复弹出
                    ,title: '您正在进行上分操作！'
                    ,btn: ['自动上分','手动上分']
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0.7 //不显示遮罩
                    ,yes: function(){
                        $.post("{:url('pay/notify/index')}",{id:data.id},function(res){
                            console.log(res);
                            if(res.code===1){
                                layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                    tableIn.reload();
                                });
                            }else{
                                layer.msg(res.msg,{time:1000,icon:2});
                            }
                        });
                        layer.closeAll();
                    }
                    ,btn2:function(){
                        $.post("{:url('order/gopoints')}",{id:data.id,points:2},function(res){
                            if(res.code===1){
                                layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                    tableIn.reload();
                                });
                            }else{
                                layer.msg(res.msg,{time:1000,icon:2});
                            }
                        });
                    } 
                });   
            }
        });  
    });  
</script>
</body>
</html>